package com.test.file;

import com.test.utils.Base64Utils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.shiro.codec.Base64;

import java.io.*;
import java.util.*;

public class ReadLeftAndRightTxt {

    public static void main(String[] args) throws Exception{
        String leftTxt = "D:/left.txt";
        String rightTxt = "D:/right.txt";
        String s = "";

        BufferedReader reader = new BufferedReader(new FileReader(leftTxt));
        Map<Long, Object> lmap = new HashMap<>();
        Map<Long, Object> rmap = new HashMap<>();

        while((s = reader.readLine()) != null ) {
            lmap.put(NumberUtils.toLong(s), null);
        }
        reader = new BufferedReader(new FileReader(rightTxt));
        while((s = reader.readLine()) != null ) {
            rmap.put(NumberUtils.toLong(s), null);
        }
        int ret = 0;
        for (Long key : lmap.keySet()) {
            if (rmap.containsKey(key)) {
                ret++;
            }
        }
        System.out.println(ret);
    }
}
